package com.simtek.simplayer.utils;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class LinkParser {

	public static String	URL_REGEX	= "(?:(?:ht|f)tp(?:s?)://)(?:(?:[-\\w]+\\.)+(?:[-\\w]+))(?::[\\d]{1,5})?(?:(?:(?:/(?:[-\\w~!$+|.,=]|%[a-f\\d]{2})+)+|/)+|\\?|#)?(?:(\\S)*)";
	public static Pattern	urlPattern	= Pattern.compile(URL_REGEX);

	public static String	HTTP_REGEX	= "([Hh][tT][tT][pP][sS]?:\\/\\/[^ ,'\">\\]\\)]*[^\\. ,'\">\\]\\)])";
	public static Pattern	httpPattern	= Pattern.compile(HTTP_REGEX);

	public static CharSequence getHttpUrl(CharSequence content) {
		final Matcher matcher = urlPattern.matcher(content);
		while (matcher.find()) {
			final String link = matcher.group();
			return link;
		}
		return null;
	}

}
